<?php
/* include library */                                       
require_once('library/shrine_core.php');  
/* logic */      
function cache_save($file,$object){
	return file_put_contents($file,serialize($object));
}
function cache_load($file,$refresh_seconds=3600){
	if( !file_exists($file) ) return null;
	$time_diff = time() - filemtime($file);
	if( $time_diff > $refresh_seconds ) return null;
	return unserialize(file_get_contents($file));
}

/* load group messages */
$cache_group_messages = cache_load('cache/group_messages');
if( $cache_group_messages ){
	$list_messages = $cache_group_messages;
}else{
	$url_rss_group = 'http://groups.google.com/group/uaca/feed/rss_v2_0_msgs.xml';
	$object_xml = simplexml_load_file($url_rss_group);
	$list_messages = array();
	foreach($object_xml->channel->item as $item) array_push($list_messages,(array)$item);
	cache_save('cache/group_messages',$list_messages);
}

/* include template */
include(RTemplate::Load('index'));

?>